def get_l2_infer(model_path):
    status_names = ['Begin',
                    'YingDaoYuanJiuWei', 'LunDangJiuWei', 'YingDaoYuanShouShi',  # 飞机就位
                    'DengJiQiao1JiuWei', 'DengJiQiao2JiuWei',  # 登机桥就位，卸人
                    'KeTiCheJiuWei?', 'DianYuanJiuWei', 'KongTiaoJiuWei?',
                    'QianHuoCangMengKai', 'HouHuoCangMengKai', 'HuoYunPingTaiJiuWei', 'HuoYunCheJiuWei', 'XieHuo1',
                    'XieHuo2',  # 卸货
                    'ShiPingCheJiuWei', 'JiaYouCheJiuWei',  # 加食品，加油
                    'QianHuoCangMengGuan', 'HouHuoCangMengGuan',  # 关门
                    'DengJiQiao2CheLi', 'DengJiQiao1CheLi',  # 撤登机桥
                    'QianYingCheJiuWei', 'FeiJiTuiChu',  # 飞机撤离
                    'End']
    status_dict = {"current_status": status_names[0], 'detected_status': {}}  # 当前状态，已检测状态
    yolov8_seg_predict = get_yolov8_seg_predict(model_path)

    def l2_infer(img):
        img_show, out_v8seg = yolov8_seg_predict(img, realtime_conf_thres=0.25, isShowMask=True)
        # out: [[xyxy], cls_ind, clsname, conf, mask][list(1 * 4), int, str, float, numpy(1 * h * w)]
        if status_dict['current_status'] == 'Begin':
            airplane_index = AlgUtil.filter_yolov8(out_v8seg, target_clsname=['airplane'], )  # 飞机
            person_index = AlgUtil.filter_yolov8(out_v8seg, target_clsname=['person'], )
            if len(airplane_index) > 0 and len(person_index) > 0:
                status_dict['current_status'] = 'YingDaoYuanJiuWei'
                xyxy = out_v8seg[person_index[0]][0]
                status_dict['detected_status']['YingDaoYuanJiuWei'] = xyxy

        elif status_dict['current_status'] == 'YingDaoYuanJiuWei':
            pass
            airplaneQianLun_index = AlgUtil.filter_yolov8(out_v8seg, target_clsname=['airplaneQianLun'], )  # 飞机前轮
            # 识别前轮挡板
            if len(airplaneQianLun_index) > 0:
                airplaneQianLun_xyxy = out_v8seg[airplaneQianLun_index[0]][0]
                img_show, airplaneQianLun_out_v8seg = yolov8_seg_predict(img, realtime_conf_thres=0.25,
                                                                         roi=airplaneQianLun_xyxy)
                qianLunDangBan_index = AlgUtil.filter_yolov8(airplaneQianLun_out_v8seg,
                                                             target_clsname=['qianLunDangBan'], )
                if len(qianLunDangBan_index) > 0:
                    qianLunDangBan_xyxy = airplaneQianLun_out_v8seg[qianLunDangBan_index[0]][0]
                    status_dict['current_status'] = 'LunDangJiuWei'
                    status_dict['detected_status']['LunDangJiuWei'] = qianLunDangBan_xyxy

    return l2_infer


{'aircraft': {'aircraft': 20, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
              'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
              'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 0},
 'cargo_door': {'aircraft': 0, 'cargo_door': 16, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
                'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0,
                'no_detection': 1},
 'chock': {'aircraft': 0, 'cargo_door': 0, 'chock': 9, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
           'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
           'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 9},
 'refueling_truck': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                     'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                     'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                     'push_back_tractor': 0, 'no_detection': 0},
 'lifting_platform': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 17,
                      'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                      'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                      'push_back_tractor': 0, 'no_detection': 0},
 'transfer_car': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                  'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                  'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                  'push_back_tractor': 0, 'no_detection': 0},
 'staff': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
           'staff': 17, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
           'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 17},
 'connecting': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                'transfer_car': 0, 'staff': 0, 'connecting': 17, 'catering_truck': 0, 'belt_loader': 0,
                'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0,
                'no_detection': 0},
 'catering_truck': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 3,
                    'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 14, 'belt_loader': 0,
                    'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                    'push_back_tractor': 0, 'no_detection': 7},
 'belt_loader': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                 'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                 'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                 'push_back_tractor': 0, 'no_detection': 0},
 'power_cable': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                 'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                 'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                 'push_back_tractor': 0, 'no_detection': 0},
 'pre_conditioning_air': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                          'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                          'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                          'push_back_tractor': 0, 'no_detection': 0},
 'thumbs_up': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
               'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
               'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0,
               'no_detection': 0},
 'ULD': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
         'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
         'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 0},
 'bag': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
         'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
         'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 37, 'bag': 3, 'push_back_tractor': 0, 'no_detection': 0},
 'push_back_tractor': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                       'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                       'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                       'push_back_tractor': 0, 'no_detection': 0},
 'no_detection': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                  'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                  'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                  'push_back_tractor': 0, 'no_detection': 0}}



{'aircraft': {'aircraft': 33, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
              'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
              'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 0},
 'cargo_door': {'aircraft': 0, 'cargo_door': 21, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
                'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0,
                'no_detection': 6},
 'chock': {'aircraft': 0, 'cargo_door': 0, 'chock': 9, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
           'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
           'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 9},
 'refueling_truck': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                     'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                     'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                     'push_back_tractor': 0, 'no_detection': 0},
 'lifting_platform': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 22,
                      'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                      'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                      'push_back_tractor': 0, 'no_detection': 0},
 'transfer_car': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                  'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                  'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                  'push_back_tractor': 0, 'no_detection': 2},
 'staff': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
           'staff': 17, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
           'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 17},
 'connecting': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                'transfer_car': 0, 'staff': 0, 'connecting': 30, 'catering_truck': 0, 'belt_loader': 0,
                'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0,
                'no_detection': 0},
 'catering_truck': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 4,
                    'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 31, 'belt_loader': 0,
                    'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                    'push_back_tractor': 0, 'no_detection': 7},
 'belt_loader': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                 'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                 'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                 'push_back_tractor': 0, 'no_detection': 0},
 'power_cable': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                 'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                 'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                 'push_back_tractor': 0, 'no_detection': 0},
 'pre_conditioning_air': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                          'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                          'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                          'push_back_tractor': 0, 'no_detection': 0},
 'thumbs_up': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
               'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
               'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0, 'push_back_tractor': 0,
               'no_detection': 0},
 'ULD': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
         'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
         'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 46, 'bag': 0, 'push_back_tractor': 0, 'no_detection': 1},
 'bag': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0, 'transfer_car': 0,
         'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0, 'power_cable': 0,
         'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 37, 'bag': 3, 'push_back_tractor': 0, 'no_detection': 0},
 'push_back_tractor': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                       'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                       'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                       'push_back_tractor': 0, 'no_detection': 0},
 'no_detection': {'aircraft': 0, 'cargo_door': 0, 'chock': 0, 'refueling_truck': 0, 'lifting_platform': 0,
                  'transfer_car': 0, 'staff': 0, 'connecting': 0, 'catering_truck': 0, 'belt_loader': 0,
                  'power_cable': 0, 'pre_conditioning_air': 0, 'thumbs_up': 0, 'ULD': 0, 'bag': 0,
                  'push_back_tractor': 0, 'no_detection': 0}}
